{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Weight  of evidence\n",
    "\n",
    "Weight of Evidence (WoE) was developed primarily for the credit and financial industries to help build more predictive models to evaluate the risk of loan default. That is, to predict how likely the money lent to a person or institution is to be lost. Thus, Weight of Evidence is a measure of the \"strength” of a grouping technique to separate good and bad risk (default). \n",
    "\n",
    "It is computed from the basic odds ratio: ln( (Proportion of Good Credit Outcomes) / (Proportion of Bad Credit Outcomes))\n",
    "\n",
    "WoE will be 0 if the P(Goods) / P(Bads) = 1. That is, if the outcome is random for that group. If P(Bads) > P(Goods) the odds ratio will be < 1 and the WoE will be < 0; if, on the other hand, P(Goods) > P(Bads) in a group, then WoE > 0.\n",
    "\n",
    "WoE is well suited for Logistic Regression, because the Logit transformation is simply the log of the odds, i.e., ln(P(Goods)/P(Bads)). Therefore, by using WoE-coded predictors in logistic regression, the predictors are all prepared and coded to the same scale, and the parameters in the linear logistic regression equation can be directly compared.\n",
    "\n",
    "The WoE transformation has three advantages:\n",
    "\n",
    "- It establishes a monotonic relationship to the dependent variable.\n",
    "- It orders the categories on a \"logistic\" scale which is natural for logistic regression\n",
    "- The transformed variables, can then be compared because they are on the same scale. Therefore, it is possible to determine which one is more predictive.\n",
    "\n",
    "The WoE also has three drawbacks:\n",
    "\n",
    "- May incur in loss of information (variation) due to binning to few categories (we will discuss this further in the discretisation section)\n",
    "- It does not take into account correlation between independent variables\n",
    "- Prone to cause over-fitting\n",
    "\n",
    "\n",
    "For more details follow this link:\n",
    "\n",
    "http://documentation.statsoft.com/StatisticaHelp.aspx?path=WeightofEvidence/WeightofEvidenceWoEIntroductoryOverview\n",
    "\n",
    "Let's see how to implement WoE in python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Cabin</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>C85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>C123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Survived Cabin\n",
       "0         0   NaN\n",
       "1         1   C85\n",
       "2         1   NaN\n",
       "3         1  C123\n",
       "4         0   NaN"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# let's load again the titanic dataset\n",
    "\n",
    "data = pd.read_csv('titanic.csv', usecols=['Cabin', 'Survived'])\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Cabin</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>Missing</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>C85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>Missing</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>C123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>Missing</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Survived    Cabin\n",
       "0         0  Missing\n",
       "1         1      C85\n",
       "2         1  Missing\n",
       "3         1     C123\n",
       "4         0  Missing"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# let's first fill NA values with an additional label\n",
    "\n",
    "data.Cabin.fillna('Missing', inplace=True)\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "148"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Cabin has indeed a lot of labels, here for simplicity, I will capture the first letter of the cabin, \n",
    "# but the procedure could be done as well without any prior variable manipulation\n",
    "\n",
    "len(data.Cabin.unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Cabin</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Survived Cabin\n",
       "0         0     M\n",
       "1         1     C\n",
       "2         1     M\n",
       "3         1     C\n",
       "4         0     M"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Now we extract the first letter of the cabin\n",
    "\n",
    "data['Cabin'] = data['Cabin'].astype(str).str[0]\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['M', 'C', 'E', 'G', 'D', 'A', 'B', 'F', 'T'], dtype=object)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# check the labels\n",
    "data.Cabin.unique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Important\n",
    "\n",
    "The calculation of the WoE to replace the labels should be done considering the ONLY the training set, and then expanded it to the test set.\n",
    "See below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((623, 2), (268, 2))"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Let's divide into train and test set\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(data[['Cabin', 'Survived']], data.Survived, test_size=0.3,\n",
    "                                                    random_state=0)\n",
    "X_train.shape, X_test.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Cabin\n",
       "A    0.428571\n",
       "B    0.774194\n",
       "C    0.571429\n",
       "D    0.692308\n",
       "E    0.740741\n",
       "F    0.666667\n",
       "G    0.500000\n",
       "M    0.303609\n",
       "T    0.000000\n",
       "Name: Survived, dtype: float64"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# now we calculate the probability of target=1 \n",
    "X_train.groupby(['Cabin'])['Survived'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Cabin</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>0.428571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0.774194</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>0.571429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>0.692308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>0.740741</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>0.666667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>0.303609</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Survived\n",
       "Cabin          \n",
       "A      0.428571\n",
       "B      0.774194\n",
       "C      0.571429\n",
       "D      0.692308\n",
       "E      0.740741\n",
       "F      0.666667\n",
       "G      0.500000\n",
       "M      0.303609\n",
       "T      0.000000"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# let's make a dataframe with the above calculation\n",
    "\n",
    "prob_df = X_train.groupby(['Cabin'])['Survived'].mean()\n",
    "prob_df = pd.DataFrame(prob_df)\n",
    "prob_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Died</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Cabin</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>0.428571</td>\n",
       "      <td>0.571429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0.774194</td>\n",
       "      <td>0.225806</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.428571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>0.692308</td>\n",
       "      <td>0.307692</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>0.740741</td>\n",
       "      <td>0.259259</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>0.303609</td>\n",
       "      <td>0.696391</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Survived      Died\n",
       "Cabin                    \n",
       "A      0.428571  0.571429\n",
       "B      0.774194  0.225806\n",
       "C      0.571429  0.428571\n",
       "D      0.692308  0.307692\n",
       "E      0.740741  0.259259\n",
       "F      0.666667  0.333333\n",
       "G      0.500000  0.500000\n",
       "M      0.303609  0.696391\n",
       "T      0.000000  1.000000"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# and now the probability of target = 0 \n",
    "# and we add it to the dataframe\n",
    "\n",
    "prob_df = X_train.groupby(['Cabin'])['Survived'].mean()\n",
    "prob_df = pd.DataFrame(prob_df)\n",
    "prob_df['Died'] = 1-prob_df.Survived\n",
    "prob_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Died</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Cabin</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>0.428571</td>\n",
       "      <td>0.571429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0.774194</td>\n",
       "      <td>0.225806</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.428571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>0.692308</td>\n",
       "      <td>0.307692</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>0.740741</td>\n",
       "      <td>0.259259</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>0.303609</td>\n",
       "      <td>0.696391</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>0.000010</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Survived      Died\n",
       "Cabin                    \n",
       "A      0.428571  0.571429\n",
       "B      0.774194  0.225806\n",
       "C      0.571429  0.428571\n",
       "D      0.692308  0.307692\n",
       "E      0.740741  0.259259\n",
       "F      0.666667  0.333333\n",
       "G      0.500000  0.500000\n",
       "M      0.303609  0.696391\n",
       "T      0.000010  1.000000"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# since the log of zero is not defined, let's set this number to something small and non-zero\n",
    "\n",
    "prob_df.loc[prob_df.Survived == 0, 'Survived'] = 0.00001\n",
    "prob_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Survived</th>\n",
       "      <th>Died</th>\n",
       "      <th>WoE</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Cabin</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>0.428571</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>-0.287682</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>0.774194</td>\n",
       "      <td>0.225806</td>\n",
       "      <td>1.232144</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.428571</td>\n",
       "      <td>0.287682</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D</th>\n",
       "      <td>0.692308</td>\n",
       "      <td>0.307692</td>\n",
       "      <td>0.810930</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E</th>\n",
       "      <td>0.740741</td>\n",
       "      <td>0.259259</td>\n",
       "      <td>1.049822</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>F</th>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.693147</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>M</th>\n",
       "      <td>0.303609</td>\n",
       "      <td>0.696391</td>\n",
       "      <td>-0.830169</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T</th>\n",
       "      <td>0.000010</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-11.512925</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Survived      Died        WoE\n",
       "Cabin                               \n",
       "A      0.428571  0.571429  -0.287682\n",
       "B      0.774194  0.225806   1.232144\n",
       "C      0.571429  0.428571   0.287682\n",
       "D      0.692308  0.307692   0.810930\n",
       "E      0.740741  0.259259   1.049822\n",
       "F      0.666667  0.333333   0.693147\n",
       "G      0.500000  0.500000   0.000000\n",
       "M      0.303609  0.696391  -0.830169\n",
       "T      0.000010  1.000000 -11.512925"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# now we calculate the WoE\n",
    "\n",
    "prob_df['WoE'] = np.log(prob_df.Survived/prob_df.Died)\n",
    "prob_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'A': -0.2876820724517809,\n",
       " 'B': 1.2321436812926321,\n",
       " 'C': 0.28768207245178085,\n",
       " 'D': 0.81093021621632877,\n",
       " 'E': 1.0498221244986774,\n",
       " 'F': 0.69314718055994518,\n",
       " 'G': 0.0,\n",
       " 'M': -0.83016897812423662,\n",
       " 'T': -11.512925464970229}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# and we create a dictionary to re-map the variable\n",
    "\n",
    "prob_df['WoE'].to_dict()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# and we make a dictionary to map the orignal variable to the WoE\n",
    "# same as above but we capture the dictionary in a variable\n",
    "\n",
    "ordered_labels = prob_df['WoE'].to_dict()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# replace the labels with the WoE\n",
    "\n",
    "X_train['Cabin_ordered'] = X_train.Cabin.map(ordered_labels)\n",
    "X_test['Cabin_ordered'] = X_test.Cabin.map(ordered_labels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Cabin</th>\n",
       "      <th>Survived</th>\n",
       "      <th>Cabin_ordered</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>857</th>\n",
       "      <td>E</td>\n",
       "      <td>1</td>\n",
       "      <td>1.049822</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>D</td>\n",
       "      <td>1</td>\n",
       "      <td>0.810930</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>386</th>\n",
       "      <td>M</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.830169</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>124</th>\n",
       "      <td>D</td>\n",
       "      <td>0</td>\n",
       "      <td>0.810930</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>578</th>\n",
       "      <td>M</td>\n",
       "      <td>0</td>\n",
       "      <td>-0.830169</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Cabin  Survived  Cabin_ordered\n",
       "857     E         1       1.049822\n",
       "52      D         1       0.810930\n",
       "386     M         0      -0.830169\n",
       "124     D         0       0.810930\n",
       "578     M         0      -0.830169"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# check the results\n",
    "\n",
    "X_train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.text.Text at 0x5af86f2978>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEWCAYAAACJ0YulAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd4FWXa+PHvnYSeUJPQIYQWitQIKB10xYqFVRDFCqKi\n69p3f7uu7+v6rqvuWkFEbKCCXXEXO6CAtID0GmpCS2gh1LT798cMeIypcE7mnOT+XFeunJl5Zp57\n5pwz95n2PKKqGGOMMQBhXgdgjDEmeFhSMMYYc5olBWOMMadZUjDGGHOaJQVjjDGnWVIwxhhzmiWF\nECAij4vIO35c3jYRueAM5+0rIhv8FUshdbwlIn8vYvoREYk/g+XGiYiKSMTZRVgxiMhEEflrCcvO\nEZHbC5kWFNs9WOIIdpYUOL2TTBORGj7jbheROR6GFRTcL1GrU8OqOldV23oZk6pGquqWsqyzIu5Q\nVHWsqj7hdRxl5Wx+LPmp/iJ/DJUVSwq/CAf+cLYLEYdn27Ui7bRM4IhIuNcxhJryss0sKfziGeBB\nEald0EQROV9ElohIhvv/fJ9pc0TkSRGZDxwD4t1xfxeRn9zTHV+ISD0ReVdEDrvLiPNZxgsikuJO\nWyoifUsStIgMEJFUEXlERPYAb7rjLxOR5SJyyI2hUyHz9xCRBW653SLysohUdqf96BZb4a7Ddafq\n85m/nbuuh0RkjYhc4TPtLREZLyL/FZFMEVkkIi3daSIiz7lHaIdFZJWIdPQJrU5B87nznj56ceuY\nKCLfumV/EJHmxWy2W0Vkl7u+D/osN0xEHhWRzSKyX0Q+EJG67uRT2+KQuy3OE5HtItLdnXekG1cH\nd/g2EfmsBMtFRHq579EhEVkhIgN8ps0RkSdEZL67ft+ISHQh7+U6EbnMZzhCRNJFpJs7/KGI7HE/\nwz+eitVnO74iIjNF5CgwUHx+uYpIHRH5j7u8g+7rJvlCaCkii93383Pfdc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SkYU7ACW5IFfhaR792+MlaJyFCfeSJE5F0RWSciH4lIdQARmSMiie7rIyLy\npNs/xEIRqV+ma2VMMSwpGFOwwlqSPQFcpardcBLHv3ya8m4LTFDVdsBh4K4C5q8BLFTVzjhP44/2\ne+TGnAVLCsaUjgD/JyIrge+AxjinlABSVHW++/odnNY988sCTvXOtRSIC1yoxpSeJQVjCrYGKKjP\njpE4rd52d5ug3gtUdaflbzOmoDZksn0a9MvFruuZIGNJwZiCFdiSLNAcSFPVbBEZ6A6f0sztQwPg\nepyuY40JKZYUjCmA+2v+KuAC95bUNTj9bc8EEkVkFTAKWO8z2wbgbhFZB9QBXinjsI05a9ZKqjHG\nmNPsSMEYY8xplhSMMcacZknBGGPMaZYUjDHGnGZJwRhjzGmWFIwxxpxmScEYY8xp/x+KMNHhJfml\nDQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x5af76905f8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plot the original variable\n",
    "\n",
    "fig = plt.figure()\n",
    "fig = X_train.groupby(['Cabin'])['Survived'].mean().plot()\n",
    "fig.set_title('Normal relationship between variable and target')\n",
    "fig.set_ylabel('Survived')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.text.Text at 0x5af8b510b8>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEXCAYAAABCjVgAAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VfWd//HXh4R9J7nsBAIkIi6oRHCBuFe07Wgd26Jt\nrbXW0dauv+7TX9uZTqfbzG/Gae1Qa6lbW8Yutk5ra1fZFAQUF1QgEELYJGGHELJ9fn+ck+v1crOS\nk3tv8n4+Hjy492z3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hDpFCUFyWrh1fw7gCvDR1I3AN8AngBKzOwl4BbgtYTVNgIfMbNXCU7M/32K\nYXwU+ICZvQi8jzcGJEr2T0BpGOMNwPZwH14BvgT8MdzGn4BxKfa1jqBU9K3whvJ64KJw9geAe81s\nPQk3sEU6Sl1ni4hInEoKIiISpxvNIu0UDiD/zqTJP3f3r6daXiQbqfpIRETiVH0kIiJxSgoiIhKn\npCAiInFKCiIiEvf/AR8/y177Kts9AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x5af86ed320>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# plot the transformed result: the monotonic variable\n",
    "\n",
    "fig = plt.figure()\n",
    "fig = X_train.groupby(['Cabin_ordered'])['Survived'].mean().plot()\n",
    "fig.set_title('Monotonic relationship between variable and target')\n",
    "fig.set_ylabel('Survived')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "As you can see in the above plot, there is now a monotonic relationship between the variable Cabin and probability of survival. The higher the Cabin number, the more likely the person was to survive.\n",
    "\n",
    "### Note\n",
    "\n",
    "Monotonic does not mean strictly linear. Monotonic means that it increases constantly, or it decreases constantly."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  },
  "toc": {
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": "block",
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
